<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>

<script>
import {gettoken} from './api/home'
export default {
  name: 'App',
  components: {

  },
  mounted(){
    // 缓存中存在token，则发送token去服务器校验token是否有效，无效退出登录页，删除缓存token
    if(localStorage.getItem('token')){
      gettoken().then(res=>{
        console.log('获取token--------------',res);
        if(res.code ==2002){
          localStorage.removeItem('token')
          this.$router.replace({
            path: '/login'
          })
        }
      })
    }
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  /* margin-top: 60px; */
}
</style>
